//
//  Push_DescriptionController.swift
//  好书
//
//  Created by 魏忠海 on 2018/4/1.
//  Copyright © 2018年 WZH. All rights reserved.
//

import UIKit

typealias Push_DescriptionControllerBlock = (_ description:String)->Void

class Push_DescriptionController: UIViewController {

    var textView:JVFloatLabeledTextView?
    
    var callBack:Push_DescriptionControllerBlock?
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        self.textView = JVFloatLabeledTextView(frame: CGRect(x: 8, y: 50, width: SCREEN_WIDTH - 16, height: SCREEN_HEIGHT - 58 - 8))
        self.view.addSubview(self.textView!)
        self.textView?.placeholder = "         你可以在这里撰写详细的评价、吐槽、介绍~~"
        self.textView?.font = UIFont(name: MY_FONT, size: 17)
        self.view.tintColor = UIColor.gray
        self.textView?.becomeFirstResponder()
        
//        XKeyBoard.registerHide(self)
        XKeyBoard.registerShow(self)
    }
    @objc func sure() {
        self.callBack!((self.textView?.text)!)
        self.dismiss(animated: true) {
            
        }
    }
    @objc func close() {
        self.dismiss(animated: true) {
            
        }
    }
    
    /// 键盘将要隐藏
    @objc func keyboardWillHideNotification(_ notification:NSNotification) {
        self.textView?.contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
    }
    
    /// 键盘将要显示
    @objc func keyboardWillShowNotification(_ notification:NSNotification) {
        let rect = XKeyBoard.returnWindow(notification as Notification?)
        self.textView?.contentInset = UIEdgeInsetsMake(0, 0, rect.size.height, 0)
        
    }

}
